<template>
  <div>
    <div>
      <van-nav-bar
          title="余额明细"
          left-arrow
          @click-left="onClickLeft"
      />
    </div>
    <!--    在这个-->
    <div v-for="(item,key) in billList" :key="key">
      <!--      盒子里面v-for数据即可-->
      <hr>
      <div class="datemessage"><span>{{ key }}</span></div>
      <div class="detail" v-for="(item1,key1) in item" :key="key1" @click="goDetailParticulars(item1)">
        <div>
          <div class="updiv">
            <span style="float: left">{{item1.classify}}</span>
            <span style="float: right">{{item1.classify=='提现'?'-':'+'}}{{item1.money}}₱</span>
          </div>
          <div class="belowdiv">
            <span style="float: left">{{item1.overTime|formatTimer}}</span>
            <span style="float: right">余额:{{item1.residueBalance}}₱</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      billList:{},
      registerIp:''
    };
  },
  methods: {
    goDetailParticulars(data){
      this.$router.push({
        path: '/detailparticulars',
        query:{
          data:data
        }
      });
    },
    onClickLeft(){
      this.$router.push({
        path: '/mywallet',
      });
    },
    getBillList(){
        axios.get('http://localhost:11219/mine/bill/getbill/'+this.registerIp).then(res=>{
        this.billList=res.data.map;
        if(this.billList==null){
          this.$toast('暂无账单');
        }
      })
    }
  },
  mounted() {
    let parse = JSON.parse(localStorage.getItem('login'));
    this.registerIp=parse.registerIp
    this.getBillList()
  },
  filters: {
    formatTimer: function(value) {
      let date = new Date(value);
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? "0" + MM : MM;
      let d = date.getDate();
      d = d < 10 ? "0" + d : d;
      let h = date.getHours();
      h = h < 10 ? "0" + h : h;
      let m = date.getMinutes();
      m = m < 10 ? "0" + m : m;
      let s = date.getSeconds();
      s = s < 10 ? "0" + s : s;
      return y + "-" + MM + "-" + d + " " + h + ":" + m;
    }
  },
}
</script>

<style scoped>
.detail{
  width: 100%;
  height: 100%;
  background-color: white;
}
.detail div{
  width: 100%;
  height: 100%;

}
.detail div div{
  width: 100%;
  height: 31px;
  margin: 1px 0;
}
.updiv span{
  margin: 0 10px;
  margin-top: 5px;
}
.belowdiv span{
  margin: 0 10px;
  margin-top: 5px;
  font-size: 13px;
  color: #a8a8a8;
}
.datemessage{
  width: 100%;
  height: 20px;
  margin: 10px 0;
}
.datemessage span{
  float: left;
  margin-top: 5px;
  margin-left: 13px;
  font-size: 13px;
  color: #000000;
}
</style>
